<template>
	<view class="page-container">
		<!-- 顶部图片区域 -->
		<view class="header">
			<image class="banner-image" :src="activityInfo.img" mode="aspectFill" />
			<!-- <view class="header-overlay">
				<view class="header-buttons">
					<uni-icons class="back-icon" type="back" size="24" color="#FFFFFF" @click="goBack" />
					<uni-icons class="share-icon" type="redo" size="24" color="#FFFFFF" @click="share" />
				</view>
			</view> -->
		</view>

		<!-- 基础信息区域 -->
		<view class="info-section">
			<text class="title">{{activityInfo.title}}</text>

			<view class="rating">
				<uni-rate :value="activityInfo.recommendScore" size="18" readonly />
				<!-- <text class="rating-text">{{activityInfo.recommendScore}}</text> -->
			</view>

			<view class="info-item">
				<uni-icons type="calendar" size="16" color="#666666" />
				<text class="info-text">{{activityInfo.startTime}} - {{activityInfo.endTime}}</text>
			</view>

			<view class="info-item location">
				<uni-icons type="location" size="16" color="#666666" />
				<text class="info-text">{{activityInfo.address}}</text>
			</view>

			<view class="highlight-notice">
				<text class="notice-text">{{activityInfo.highLight}}</text>
			</view>
		</view>

		<!-- 价格区域 -->
		<view class="price-section">
			<view class="price-info">
				<text class="price-label">门票价格</text>
				<text class="price-value">{{activityInfo.price}}</text>
			</view>

			<view v-if="activityInfo.website" class="website" @click="openWebsite(activityInfo.website)">
				<uni-icons type="link" size="16" color="#666666" />
				<text class="website-text">访问官方网站</text>
			</view>
		</view>

		<!-- 详细介绍 -->
		<view class="detail-section">
			<text class="section-title">活动详情</text>
			<rich-text :nodes="activityInfo.descriptionDom"></rich-text>
		</view>

		<!-- 额外信息 -->
		<view class="extra-section">
			<uni-collapse>
				<uni-collapse-item title="重要提示">
					<view class="notice-content">
						<text class="notice-item">{{activityInfo.remarks}}</text>
					</view>
				</uni-collapse-item>
			</uni-collapse>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import uniRequest from '@/components/request.js';
	let activityInfo = ref({})

	onLoad((options) => {
		uniRequest({
			url: 'https://suixinyou.top:5066/2c/scenic/activity/getActivityDetail/' + options.id,
			method: 'GET',
			success(res) {
				activityInfo.value = res.data.data
			},
			fail(err) {
				console.log('请求失败', err);
			},
			complete() {
				console.log('请求完成');
			}
		})
	})

	const goBack = () => {
		uni.navigateBack();
	};

	const share = () => {
		uni.showShareMenu({
			withShareTicket: true
		});
	};

	const navigateToMap = () => {
		uni.openLocation({
			latitude: 30.2587,
			longitude: 120.1485,
			name: '西湖断桥残雪景区',
			address: '浙江省杭州市西湖区断桥残雪景区'
		});
	};

	const openWebsite = (url) => {
		uni.setClipboardData({
			data: url,
			success: () => {
				uni.showToast({
					title: '网址已复制',
					icon: 'success'
				});
			}
		});
	};
</script>

<style>
	page {
		height: 100%;
	}

	.page-container {
		min-height: 100%;
		background-color: #F5F5F5;
	}

	.header {
		position: relative;
		width: 750rpx;
		height: 500rpx;
	}

	.banner-image {
		width: 100%;
		height: 100%;
	}

	.header-overlay {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 50%);
	}

	.header-buttons {
		display: flex;
		justify-content: space-between;
		padding: 40rpx;
	}

	.back-icon,
	.share-icon {
		width: 48px;
		height: 48px;
		display: flex;
		align-items: center;
		justify-content: center;
		background: rgba(0, 0, 0, 0.3);
		border-radius: 24px;
	}

	.info-section {
		padding: 30rpx;
		background: #FFFFFF;
		margin-bottom: 20rpx;
	}

	.title {
		font-size: 20px;
		font-weight: bold;
		color: #333333;
		margin-bottom: 20rpx;
	}

	.rating {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.rating-text {
		font-size: 14px;
		color: #666666;
		margin-left: 10rpx;
	}

	.info-item {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.info-text {
		font-size: 14px;
		color: #666666;
		margin-left: 10rpx;
		flex: 1;
	}

	.location {
		padding: 20rpx 0;
		border-top: 1px solid #EEEEEE;
		border-bottom: 1px solid #EEEEEE;
	}

	.highlight-notice {
		margin-top: 20rpx;
		padding: 20rpx;
		background: rgba(255, 87, 34, 0.1);
		border-radius: 8px;
	}

	.notice-text {
		font-size: 14px;
		color: #FF5722;
	}

	.price-section {
		padding: 30rpx;
		background: #FFFFFF;
		margin-bottom: 20rpx;
	}

	.price-info {
		display: flex;
		align-items: baseline;
		margin-bottom: 20rpx;
		flex-wrap: nowrap;
		/* 确保标签和价格在一行 */
		max-width: 100%;
	}

	.price-label {
		font-size: 14px;
		color: #666666;
		margin-right: 20rpx;
		white-space: nowrap;
	}

	.price-value {
		font-size: 24px;
		color: #FF5722;
		font-weight: bold;
		word-break: break-word;
		/* 允许价格换行 */
		max-width: 80%;
	}

	.price-unit {
		font-size: 14px;
		color: #999999;
		margin-left: 4rpx;
	}

	.website {
		display: flex;
		align-items: center;
	}

	.website-text {
		font-size: 14px;
		color: #666666;
		margin-left: 10rpx;
		text-decoration: underline;
	}

	.detail-section {
		padding: 30rpx;
		background: #FFFFFF;
		margin-bottom: 20rpx;
	}

	.section-title {
		font-size: 16px;
		font-weight: bold;
		color: #333333;
		margin-bottom: 20rpx;
		display: block;
	}

	.extra-section {
		padding: 0 30rpx;
		background: #FFFFFF;
		margin-bottom: 120rpx;
	}

	.notice-content {
		padding: 20rpx 0;
	}

	.notice-item {
		font-size: 14px;
		color: #666666;
		line-height: 1.6;
		display: block;
	}

	.bottom-button {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		padding: 20rpx 30rpx;
		background: #FFFFFF;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
	}

	.bottom-button .uni-button {
		background: #FF5722;
		border-color: #FF5722;
	}
</style>